import { Router } from 'express'
import { update } from '../../db/dao'
import { MONEY } from '../../db/model'

const router = Router()

router.put('/update', function (req, res) {
  const balance = req.body
  const id = 1
  if (balance < 0) {
    return res.status(400).send('参数有误')
  }
  update(MONEY, {
    id: id
  }, balance).then(result => {
    res.status(200).json(result)
  }).catch(() => {
    res.status(500).end()
  })
})

export default router
